export default class Song {
  constructor({
    id,
    mid,
    singer,
    name,
    album,
    duration,
    image ,
    url
  }) {
    this.id = id
    this.mid = mid
    this.singer = singer
    this.name = name
    this.album = album
    this.duration = duration
    this.image = image
    this.url = url
  }
}

export function createSong(musicData) {
  return new Song({
    id: musicData.songid,
    mid: musicData.songmid,
    singer: filterSinger(musicData.singer),
    name: musicData.songname,
    album: musicData.albumname,
    duration: musicData.interval,
    image: `https://y.gtimg.cn/music/photo_new/T002R300x300M000${musicData.albummid}.jpg?max_age=2592000`,
    url: `http://dl.stream.qqmusic.qq.com/${musicData.songid}.m4a? vkey=BDDF6081BD6AB8C0758891D197B82CFDD3F4B78CF2BE22678761B07F05C30819A38B6751D98312EDFCA8FBDA1B5A4E888C2BA02BE927B042&guid=3230841516&uin=0&fromtag=46`
  })
 
}
function filterSinger(singer){
    let ret = [];
    if(!singer){
        return ''
    }
    singer.forEach((s) => {
        ret.push(s.name)
    });
    return ret.join('/');
}
